<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 指令：v-bind,v-if,v-model....不同的指令能实现不同的功能 -->
        <input type="text" v-bind:value="msg" v-on:input="valueChange">
        <p>{{msg}}</p>
        <input type="text" v-focus>
    </div>
</body>
<script>
    const { createApp } = Vue;
    const app = createApp({
        el: "#app",
        data() {
            return {
                msg: "helloworld"
            }
        },
        methods: {
            valueChange(e) {
                this.msg = e.target.value
            }
        }
    })
    // 自定义指令
    app.directive("focus", {
        mounted(el) {
            // el表示所绑定的元素
            console.log(el);
            el.focus()
        }
    })
    app.mount("#app")
</script>

</html>